package com.cbdp.dao.util;

import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * com.cbdp.dao.util
 *
 * @author 白雨浓
 * date: 2018/10/26 15:19
 * content:
 */
public class LocalDateTimeTypeResolver extends JavaTypeResolverDefaultImpl {

    public LocalDateTimeTypeResolver() {
    }

    @Override
    public FullyQualifiedJavaType calculateJavaType(IntrospectedColumn introspectedColumn) {
        FullyQualifiedJavaType fullyQualifiedJavaType = super.calculateJavaType(introspectedColumn);
        if (Date.class.getCanonicalName().equals(fullyQualifiedJavaType.getFullyQualifiedName())) {
            return new FullyQualifiedJavaType(LocalDateTime.class.getCanonicalName());
        }
        return fullyQualifiedJavaType;
    }
}